export enum ChannelType {
  lark = 'lark',
  apikey = 'apikey',
}

export type Permission = {
  resource_id: string;
  resource_type: string;
  action: string;
  name: string;
  resource_name?: string;
};

export type Sharelink = {
  id?: string;
  share_code?: string;
  name: string;
  description: string;
  iat: number;
  exp: number;
  status: boolean;
  permissions?: Permission[];
  created_time?: string;
  updated_time?: string;
};

export type ChannelLimit = {
  maxUsagePoints?: number;
  QPM?: number;
  expiredTime?: string;
  hookUrl?: string;
};

export type ChannelApp = {
  larkId: string;
  larkSecret: string;
};

export type ChannelPermission = {
  resource_type: string;
  resource_id: string;
  resource_name: string;
  action: string;
};

export type ChannelBase = {
  id?: string;
  name: string;
  appId: string;
  type: ChannelType;
  permissions: ChannelPermission[];
  limit: ChannelLimit;
};

export type Channel = ChannelBase & {
  shareId?: string;
  teamId?: string;
  tmbId?: string;
  app: ChannelApp;
  groupId?: string;
  webhookUrl?: string;
};
